from lxml import etree
tree = etree.parse('xpath_test01.html')

#查询li中id包含l的标签
li_list = tree.xpath('//ul/li[contains(@id,"l")]/text()')
print(li_list)
print(len(li_list))

#查询id的值以l开头的li标签
li_listt = tree.xpath('//ul/li[starts-with(@id,"c")]/text()')
print(li_listt)

li_listtt = tree.xpath('//ul/li[@id = "l1"/text() | //ul/li[@id = "l2"/text()')
print(li_listtt)
